<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>图书后台管理系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="../Xadmin/css/font.css">
    <link rel="stylesheet" href="../Xadmin/css/xadmin.css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="../layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../Xadmin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        var is_remember = false;
    </script>
</head>
<body>
<div class="layui-form-item">
    <label class="layui-form-label">图书编号：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="bookid" id="bookid" autocomplete="off" style="width: 30rem;" />
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">书名：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="BName" id="BName" autocomplete="off" style="width: 30rem;" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">价格：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="jiage" id="jiage" autocomplete="off" style="width: 30rem;" ></input>
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">是否已经出售：</label>
    <div class="layui-input-block">
        <input class="layui-input" name="IsTrue" id="IsTrue" autocomplete="off" style="width: 30rem;"/>
    </div>
</div>
<button class="layui-btn" style="margin-left:20rem" onclick="addTime()">添加</button>
</body>
<script>
    layui.use('layer', function () {
        console.log('layer导入成功！')
    })
    function addTime(){
        $.ajax({
            url:"http://127.0.0.1:8081/BookTime/BookTime",
            method:"post",
            data:{
                bookid:$("#bookid").val(),
                BName:$("#BName").val(),
                IsTrue:$("#IsTrue").val(),
                jiage:$("#jiage").val()
            },
            success: function (res) {
                var object = JSON.parse(res)
                if (object.code === '0') {
                    layer.alert("添加成功")
                } else {
                    layer.alert("添加失败")
                }
                reload()
            }
            })
    }
    function reload() {//刷新表格
        var table = layui.table;
        table.reload('BookName', {
            url: "http://127.0.0.1:8081/BookTime/BookTime",
            request: {
                pageName: 'page' //页码的参数名称，默认是page
                , limitName: 'limit'//每页的数量参数名称 默认是limit
            },
            where: {//查询条件
                bookid: ''
                , BName: ''
                , jiage: ''
                , IsTrue: ''
                , Ttime: ''
            },
            page: {//当前显示的页码
                curr: 1
            }

        })
    }
</script>
</html>